<template>
  <div class="page-container">
    <Header />

    <div class="main-container">
      <div class="content-grid">
        <!-- 左边栏 -->
        <div class="left-column">
          <!-- 标签名称 -->
          <div class="tag-header">
            <i class="tag-icon"></i>
            {{ tagName }}
          </div>

          <ArticleList :tagId="route.params.tagId"></ArticleList>
        </div>

        <!-- 右边栏 -->
        <div class="right-column">
          <CategoryCard></CategoryCard>
        </div>
      </div>
    </div>

    <Footer />
  </div>
</template>

<script setup>
import Header from '@/layouts/components/Header.vue'
import Footer from '@/layouts/components/Footer.vue'
import { useRoute } from 'vue-router'
import { ref } from 'vue'
import ArticleList from '@/components/ArticleList.vue'
import CategoryCard from '@/components/CategoryCard.vue'

const route = useRoute()
const tagName = ref(route.params.name)
</script>

<style scoped>
.page-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-container {
  flex: 1;
  max-width: 1230px;
  margin: 0 auto;
  margin-top: 20px;
}

.content-grid {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 20px;
}

.left-column, .right-column {
  padding: 0 12px;
}

.tag-header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 20px;
  color: #4b5563;
}

.tag-icon {
  width: 24px;
  height: 24px;
  margin-right: 8px;
  background: url('../assets/icons/tag.png') no-repeat center;
  background-size: contain;
}

.sticky-sidebar {
  position: sticky;
  top: 84px;
}

.category-box {
  padding: 20px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 12px;
}

.category-title {
  margin-bottom: 8px;
  font-weight: bold;
  text-transform: uppercase;
  color: #111827;
}

.category-list {
  font-size: 14px;
}

.category-item {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  color: #111827;
}

.category-item:hover {
  background-color: #f3f4f6;
  color: #1d4ed8;
}

.folder-icon {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  background: url('../assets/icons/folder.png') no-repeat center;
  background-size: contain;
}

/* 响应式布局 */
@media (max-width: 768px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}
</style>